package com.craiglarman.monopoly.domain;

import java.util.List;

public class Player {

	Square location;
	List<Die> dice;
	Board board ;
	private float cash = 0;
	
	public Player(Board board, List<Die> dice) {
		this.board = board;
		this.dice  = dice;
		this.location = board.getFirstSquare();
	}


	public int getDiceTotal() {
		int diceTotal = 0;
		for ( Die die : dice ) {
			diceTotal += die.getFaceValue();
		}
		return  diceTotal;
	}

	public Square getLocation() {
		return this.location;
	}

	public void takeTurn() {
		for ( Die die : dice ) {
				die.roll();
		}
		location = board.getSquare(location, getDiceTotal());
	}

	public List<Die> getDice() {
		return this.dice;
	}

	public Board getBoard() {
		return this.board;
	}

	public void setCash(float cash) {
		this.cash = cash;
	}

	public float getCash() {
		return this.cash;
	}

	public void adjustCash(float amount) {
		this.cash+=amount;
	}

	public void setLocation(Square newLocation) {
		this.location=newLocation;
	}

	public float getNetWorth() {
		return getCash();
	}

}
